package edu.gdin.ecommerce.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import edu.gdin.ecommerce.model.DicDetail;
import edu.gdin.ecommerce.model.DicType;
import edu.gdin.ecommerce.util.Pager;

@Repository("dicDetailDAO")
public class DicDetailDAO extends BaseDAO {

	public Pager queryDicDetail(DicDetail dDetail, int cPage, int pageSize) {
		String hql = "from DicDetail p where 1=1 ";
		
		String pdName = dDetail.getName();
		String pdValue = dDetail.getValue();
		
		hql += pdName.equals("")? "" : "and p.name like '%" + pdName +"%'";
		hql += pdValue.equals("")? "" : "and p.value like '%" + pdValue +"%'";
		
		return	this.getPage(hql, cPage);
	}

	public Pager queryDIcDetailByDicTypeId(String dicTypeId, Integer cPage) {
		String hql = "from DicDetail p where 1=1 and p.dicType.dicTypeId = '"+dicTypeId+"'";
		return	this.getPage(hql, cPage);
	}

}
